package com.itjiange;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ItJianGe
 * @data 2024/8/21 10:43
 */
public class SubjectImpl implements Subject {

    private final List<Observer> observers = new ArrayList<>();

    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObserver() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}
